import type { StringifyOptions } from 'query-string';

export const queryStringStringifyOption: StringifyOptions = <const>{
    encode: false,
    skipEmptyString: true,
    skipNull: true,
    sort: false,
};

export const enum SystemRouter {
    TOKEN = 'token',
    COMMON = 'common',
    DATA_LIB = 'data-lib',
    BASIC_DATA = 'basic-data',
    TREE = 'tree',
    DEVICE = 'device',
}

export const enum SystemModule {
    COMMON = 'common',
    FREEDOM = 'freedom',
    FUNCTION_BLOCK = 'function-block',
    FUNCTION_TEMPLATE = 'function-template',
    PROJECT = 'project',
    PROJECT_TEMPLATE = 'project-template',
    MARCO_FIlE = 'marco',
    EPLAN_MARCO_FILE = 'marco-file',

    /* basic data */
    ENUM_DICT = 'enum-dict',
    PHYSICAL_QUANTITY = 'physical-quantity',
    BRAND = 'brand',
    BRANCH = 'branch',
    SERIES = 'series',
}

export const SystemModuleRouter = <const>{
    TOKEN: SystemRouter.TOKEN,

    FUNCTION_BLOCK: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemModule.FUNCTION_BLOCK}`,
    FUNCTION_BLOCK_TREE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemRouter.TREE}/${SystemModule.FUNCTION_BLOCK}`,
    FUNCTION_TEMPLATE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemModule.FUNCTION_TEMPLATE}`,
    FUNCTION_TEMPLATE_TREE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemRouter.TREE}/${SystemModule.FUNCTION_TEMPLATE}`,
    PROJECT: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemModule.PROJECT}`,
    PROJECT_TREE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemRouter.TREE}/${SystemModule.PROJECT}`,
    PROJECT_TEMPLATE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemModule.PROJECT_TEMPLATE}`,
    PROJECT_TEMPLATE_TREE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemRouter.TREE}/${SystemModule.PROJECT_TEMPLATE}`,

    ENUM_DICT: `/${SystemRouter.DATA_LIB}/${SystemModule.ENUM_DICT}`,
    PHYSICAL_QUANTITY: `/${SystemRouter.BASIC_DATA}/${SystemModule.PHYSICAL_QUANTITY}`,
    BRAND: `/${SystemRouter.BASIC_DATA}/${SystemModule.BRAND}`,
    BRANCH: `/${SystemRouter.BASIC_DATA}/${SystemModule.BRAND}/${SystemModule.BRANCH}`,
    SERIES: `/${SystemRouter.BASIC_DATA}/${SystemModule.BRAND}/${SystemModule.SERIES}`,

    MARCO_FIlE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemRouter.TREE}/${SystemModule.MARCO_FIlE}`,
    EPALN_MARCO_FIlE_TREE: `/${SystemRouter.COMMON}/${SystemRouter.DATA_LIB}/${SystemRouter.TREE}/${SystemModule.MARCO_FIlE}`,
    EPALN_MARCO_FIlE: `/${SystemModule.EPLAN_MARCO_FILE}`,
    DEVICE: `/${SystemRouter.DEVICE}`,
};

export const enum ModuleApiPrefix {
    API_PROXY_MANAGEMENT = '/eplan/proxy/',
    API_PHYSICAL_QUANTITY = 'basic-data/physical-quantity',
    API_CATEGORY_MANAGE = 'basic-data/category',
    FUNCTION_UNIT = 'basic-data/function-unit',
    API_PARTS = 'basic-data/component-lib',
    API_BRAND = 'basic-data/brand',
    API_SUPPLIER = 'basic-data/supplier',
    API_PARTS_DETAIL = 'basic-data/component',
    API_PARTS_GROUP = 'basic-data/component-group',
    API_BIZ_DICT = 'biz-dict',
    TEMPLATE_SELECTION = 'template/selection',
}

export const apiPrefix = <const>'/api';
export const getApiParams: () => {
    apiPrefix: string;
} = () => {
    const prefix = `${apiPrefix}`;

    return {
        apiPrefix: prefix,
    };
};

export const defaultFontSize = <const>12;

export const host = <const>'/';
export const editorPathName = <const>'editor';
export const editorPath = <const>`/${editorPathName}`;

export const defaultPathRoute = <const>'/welcome';
export const tokenKey = <const>'Blade-Auth';
export const tokenType = <const>'bearer';
export const userTypeKey = <const>'User-Type';
export const userTypeValue = <const>'web';
export const authorizationKey = <const>'Authorization';
export const authorizationValue = <const>'Basic c3dvcmQ6c3dvcmRfc2VjcmV0';
export const defaultTenantId = <const>'000000';
export const requestTimeout = <const>30 * 1000;

export const defaultDate = <const>'';
export const defaultDateStr = <const>'';
export const defaultTimeFormatter = <const>'yyyy-MM-DD HH:mm';
export const defaultPollingTimeFormatter = <const>'HH:mm:ss';
export const defaultRequestTimeFormatter = <const>'YY-MM-DD HH:mm:ss';

export const defaultInterfaceDebounce = <const>300;
export const defaultInputDebounce = <const>300;
export const defaultInputWidth = <const>'md';
export const defaultSelectWidth = <const>'md';
export const defaultSearchSelectWidth = <const>'md';
export const defaultTextAreaWidth = <const>'md';
export const defaultUploadDraggerWidth = <const>'md';
export const defaultModalWidth = <const>'90%';
export const defaultModalMaxHeight = <const>'80%';

export const defaultSizeOfEditableTable = <const>'small';

export const defaultGridRows = <const>24;
export const defaultRootParentId = <const>'0';

export const defaultTableRowKey = <const>'id';
export const defaultTableScroll = <const>'max-content';
export const defaultTablePolling = <const>50000;
export const defaultTableDebounce = <const>100;
export const defaultTablePersistenceType = <const>'sessionStorage';
export const defaultTableColumnEmptyText = <const>'--';
export const defaultTableSearchSpan = <const>{
    xs: 24,
    sm: 24,
    md: 12,
    lg: 8,
    xl: 6,
    xxl: 6,
};

export const defaultDescriptionCol = <const>{
    xs: 1,
    sm: 2,
    md: 3,
    lg: 4,
};

export const defaultPageTotal = <const>0;
export const defaultPageCurrent = <const>1;
export const defaultPageSize = <const>10;
export const defaultPageSizeOption = ['5', '10', '50', '100'];

export const defaultWaterMark = <const>'EP';
export const maxlabelsLength = <const>20;
export const defaultRandomLength = <const>4;

export const loginTitle = <const>'EP';
export const storageInfo = <const>'epInfo';
export const storageToken = <const>'epToken';
export const storageAuthority = <const>'epAuthority';
export const redirectTargetKey = <const>'redirectTo';
